package dancrawler.client.gamecmd;

import dancrawler.common.Misc;
import dancrawler.client.Client;
import dancrawler.client.Tile;
import dancrawler.proto.cmd.CmdHandler;

import dancrawler.server.netMsg;

/**
 *
 */
public class CmdSetTile extends CmdHandler {
    private Client client;
    protected int[] args = {2,2,2};
    public CmdSetTile(Client client)
    {
        this.client = client;
    }

    @Override
    public void handleCmd(netMsg msg) {
        int x = Misc.bytesToShort(msg.getArgs()[0]);
        int y = Misc.bytesToShort(msg.getArgs()[1]);
        Tile t  = client.getRec().getTile(Misc.bytesToShort(msg.getArgs()[2]));
        client.getWorld().setTile(x, y, new Tile(x, y, t.getType(), t.collides()));
    }



    @Override
    public int getId() {
        return 8;
    }

 

    @Override
    public CmdHandler getHandler() {
        return this;
    }

}
